package com.annotation.config;

import com.annotation.conditional.WhiteCondition;
import com.annotation.conditional.WindowCondition;
import com.annotation.dao.PersonDao;
import com.annotation.entities.Person;
import com.annotation.typefilter.MyFilterType;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;

@ComponentScan(value = "com.annotation",useDefaultFilters = false,
        includeFilters = {
            @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class,ControllerAdvice.class}),
            @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {PersonDao.class}),
            @ComponentScan.Filter(type = FilterType.CUSTOM,classes = {MyFilterType.class})
        }
)
@Conditional({WindowCondition.class})
@Configuration
public class MainConfig {

    @Conditional({WhiteCondition.class})
    @Bean(name = "person")
    public Person person(){
        Person person = new Person();
        person.setId(1);
        person.setName("lqf");
        person.setEmail("lqf@163.com");
        return person;
    }
}
